import { build, BuildOptions } from "@/index.ts"
import { program } from "commander"
import { argv } from "node:process"
import manifest from "../package.json" with { type: "json" }

program
  .name(manifest.name)
  .description(manifest.description)
  .version(manifest.version)
  .option("-r --root <root>", "package.json 所在的包根目录")
  .option("-s --src <src>", "输入目录，输入的相对路径基于此")
  .option("-o --out <out>", "输出目录，输出的相对路径基于此")
  .option("-l --lib <lib>", "库入口的 glob 模式匹配字符串")
  .option("-b --bin <bin>", "二进制入口的 glob 模式匹配字符串")
  .option("--no-command-line <noCommandLine>", "禁用命令行输出")
  .action(async (options: BuildOptions & { noCommandLine: boolean }) => {
    return build(options, !options.noCommandLine)
  })
  .parse(argv)
